<template>
  <el-container class="main_container">
    <!--头部布局-->
    <el-header>
      <!--logo和项目名称-->
      <div class="left-box">
        <img src="../assets/img/logo.png" />
        <span>物流管理系统</span>
      </div>
      <!--用户头像信息-->
      <div class="right-box">
        <el-dropdown>
          <img src="../assets/img/avatar.jpg" />
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item icon="el-icon-house">首页</el-dropdown-item>
            <el-dropdown-item icon="el-icon-ship">交流</el-dropdown-item>
            <el-dropdown-item icon="el-icon-switch-button"
              >退出登录</el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>
    <el-container>
      <!--侧边栏-->
      <el-aside width="isCollapse?'60px':'200px'">
        <!--展开收起按钮-->
        <div class="toggle_box" @click="toggleCollapse">|||</div>
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          background-color="#001529"
          text-color="#fff"
          active-text-color="#ffd04b"
          :collapse="isCollapse"
          :unique-opened="true"
          :collapse-transition="false"
          :router="true"
        >
          <MenuTree :menuList="this.menuList"></MenuTree>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
import MenuTree from "./MenuTree.vue";

export default {
  components: {
    MenuTree,
  },
  data() {
    return {
      isCollapse: false,
      menuList: [
        {
          id: 1,
          parentId: 0,
          menuName: "个人信息",
          url: "",
          icon: "el-icon-setting",
          orderNum: 1,
          open: 1,
          disabled: false,
          perms: null,
          type: 0,
          children: [
            {
              id: 253,
              parentId: 1,
              menuName: "欢迎页面",
              url: "/welcome",
              icon: "el-icon-star-off",
              orderNum: 1,
              open: 0,
              disabled: false,
              perms: "welcome:view",
              type: 0,
              children: [],
            },
            {
              id: 226,
              parentId: 1,
              menuName: "基本信息",
              url: "/users",
              icon: "el-icon-user",
              orderNum: 2,
              open: 0,
              disabled: false,
              perms: "users",
              type: 0,
              children: [],
            },
          ],
        },
        {
          id: 2,
          parentId: 0,
          menuName: "员工管理",
          url: "",
          icon: "el-icon-s-goods",
          orderNum: 2,
          open: 0,
          disabled: false,
          perms: null,
          type: 0,
          children: [
            {
              id: 229,
              parentId: 312,
              menuName: "员工信息",
              url: "/Employee",
              icon: "el-icon-date",
              orderNum: 1,
              open: 1,
              disabled: false,
              perms: "el-icon-date",
              type: 0,
              children: [],
            },
          ],
        },
        {
          id: 3,
          parentId: 0,
          menuName: "客户管理",
          url: "",
          icon: "el-icon-platform-eleme",
          orderNum: 3,
          open: 0,
          disabled: false,
          perms: "",
          type: 0,
          children: [
            {
              id: 273,
              parentId: 303,
              menuName: "客户信息",
              url: "/client",
              icon: "el-icon-s-opportunity",
              orderNum: 1,
              open: 1,
              disabled: false,
              perms: "map:view",
              type: 0,
              children: [],
            },
          ],
        },
        {
          id: 4,
          parentId: 0,
          menuName: "基础信息",
          url: "",
          icon: "el-icon-s-marketing",
          orderNum: 5,
          open: 0,
          disabled: false,
          perms: "",
          type: 0,
          children: [
            {
              id: 297,
              parentId: 295,
              menuName: "监控管理",
              url: "",
              icon: "el-icon-warning",
              orderNum: 1,
              open: 0,
              disabled: false,
              perms: "",
              type: 0,
              children: [
                {
                  id: 298,
                  parentId: 297,
                  menuName: "SQL监控",
                  url: "/druid",
                  icon: "el-icon-view",
                  orderNum: 1,
                  open: 0,
                  disabled: false,
                  perms: null,
                  type: 0,
                  children: [],
                },
              ],
            },
            {
              id: 318,
              parentId: 295,
              menuName: "图标管理",
              url: "/icons",
              icon: "el-icon-star-off",
              orderNum: 2,
              open: 1,
              disabled: false,
              perms: "",
              type: 0,
              children: [],
            },
          ],
        },
        {
          id: 5,
          parentId: 0,
          menuName: "货物信息",
          url: "",
          icon: "el-icon-camera",
          orderNum: 6,
          open: 0,
          disabled: false,
          perms: null,
          type: 0,
          children: [
            {
              id: 271,
              parentId: 5,
              menuName: "审核货物",
              url: "/checkgoods",
              icon: "el-icon-date",
              orderNum: 1,
              open: 0,
              disabled: false,
              perms: "login:log",
              type: 0,
              children: [],
            },
            {
              id: 307,
              parentId: 5,
              menuName: "货物信息(1)",
              url: "/goodsinfo",
              icon: "el-icon-edit",
              orderNum: 1,
              open: 1,
              disabled: false,
              perms: "",
              type: 0,
              children: [],
            },
            {
              id: 306,
              parentId: 5,
              menuName: "货物信息(2)",
              url: "/goodsinfoimg",
              icon: "el-icon-edit",
              orderNum: 1,
              open: 1,
              disabled: false,
              perms: "",
              type: 0,
              children: [],
            },
          ],
        },
        {
          id: 6,
          parentId: 0,
          menuName: "货物运输",
          url: "",
          icon: "el-icon-camera",
          orderNum: 6,
          open: 0,
          disabled: false,
          perms: null,
          type: 0,
          children: [
            {
              id: 271,
              parentId: 5,
              menuName: "运输途中",
              url: "/loginLog",
              icon: "el-icon-date",
              orderNum: 1,
              open: 0,
              disabled: false,
              perms: "login:log",
              type: 0,
              children: [],
            },
            {
              id: 307,
              parentId: 5,
              menuName: "货物运达",
              url: "/logs",
              icon: "el-icon-edit",
              orderNum: 1,
              open: 1,
              disabled: false,
              perms: "",
              type: 0,
              children: [],
            },
            {
              id: 308,
              parentId: 5,
              menuName: "货物验收",
              url: "/logs",
              icon: "el-icon-edit",
              orderNum: 1,
              open: 1,
              disabled: false,
              perms: "",
              type: 0,
              children: [],
            },
          ],
        },
      ],
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    toggleCollapse() {
      this.isCollapse = !this.isCollapse;
    },
  },
};
</script>

<style>
* {
  padding: 0;
  margin: 0;
}
/*设置整个容器*/
.main_container {
  height: 100%;
}

/*头部布局*/
.el-header {
  background-color: #001529;
  display: flex;
  justify-content: space-between;
  padding-left: 0px;
  color: #ffffff;
  align-items: center;
  font-size: 20px;
}
.el-header .left-box {
  display: flex;
  align-items: center;
}
.el-header .left-box img {
  width: 50px;
  height: 50px;
  margin: 5px 0px 5px 15px;
}

.el-header .left-box span {
  margin-left: 15px;
}

.right-box .el-dropdown > img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: #ffffff;
  margin: 0px 0px -5px 0px;
  background-size: contain;
}

/*侧边栏*/
.el-aside {
  background-color: #001529;
  height: 600px;
}
.el-aside .toggle_box {
  background-color: chocolate;
  font-size: 15px;
  font-weight: bold;
  line-height: 24px;
  color: #ffffff;
  text-align: center;
}

.el-aside .el-menu {
  border-right: none;
}

.el-aside .el-main {
  background-color: #e9eef3;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-aside .el-dropdown-link {
  cursor: pointer;
  color: #409eff;
}

.el-aside .el-icon-arrow-down {
  font-size: 12px;
}
</style>
